home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / uucp103d / part06 < prev    next >
Encoding:
Internet Message Format  |  1990-02-04  |  60.7 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i050: uucp 1.03D - unix compatible uucp/mail/news system, Part06/16
  5. Message-ID: <11289@xanth.cs.odu.edu>
  6. Date: 4 Feb 90 02:33:57 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: overload!dillon (Matt Dillon)
  9. Lines: 2272
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12.  
  13. Submitted-by: overload!dillon (Matt Dillon)
  14. Posting-number: Volume 90, Issue 050
  15. Archive-name: unix/uucp-1.03d/part06
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 6 (of 16)."
  24. # Contents:  Disk2.contents man/Domains man/Tar
  25. #   src/News060/Anews/anews.c src/dmail/commands.c
  26. #   src/dmail/sendmail.c
  27. # Wrapped by tadguy@xanth on Sat Feb  3 20:51:10 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'Disk2.contents' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'Disk2.contents'\"
  31. else
  32. echo shar: Extracting \"'Disk2.contents'\" \(9104 characters\)
  33. sed "s/^X//" >'Disk2.contents' <<'END_OF_FILE'
  34. X
  35. XArchive ../uucp1.03D.zoo.2:
  36. XLength    CF  Size Now  Date      Time
  37. X--------  --- --------  --------- --------
  38. X   44056  49%    22470  29 Dec 89 20:13:44     uucp1/man/dme.doc
  39. X     193  13%      168  10 Jan 90 12:43:06     uucp1/man/expandm
  40. X     403  21%      317   8 Jan 90 17:21:06     uucp1/man/TrimFile
  41. X    1492  29%     1065  23 Oct 89 15:50:50     uucp1/man/UUSer
  42. X   18172  45%    10071  14 Oct 89 15:36:50     uucp1/man/MAPS
  43. X    1441  45%      790  14 Oct 89 15:36:24     uucp1/man/UPDATES
  44. X   49150  57%    21032  14 Oct 89 15:36:32     uucp1/man/how2usenet
  45. X   89791  53%    42431   3 Nov 89 15:44:36     uucp1/man/Standards
  46. X    6833  55%     3109  14 Oct 89 15:36:46     uucp1/man/NewsGroups
  47. X    1960  39%     1195   5 Jan 90 16:48:12     uucp1/man/Aliases
  48. X     749  18%      616  14 Oct 89 15:36:46     uucp1/man/MapExample
  49. X   12488  48%     6505  25 Jan 90 22:28:16     uucp1/man/GNU-LICENSE
  50. X     320  14%      276  10 Jan 90 19:00:32     uucp1/man/PhoneBook
  51. X    1990  35%     1294  10 Jan 90 10:53:20     uucp1/man/Assigns
  52. X    5912  43%     3369   8 Jan 90 23:21:56     uucp1/man/dmail
  53. X    5367  46%     2898   3 Nov 89 16:13:56     uucp1/man/Compress
  54. X    2893  34%     1898  10 Jan 90 15:40:36     uucp1/man/UUCico
  55. X    6005  44%     3343  27 Oct 89 22:27:32     uucp1/man/Getty
  56. X    4580  40%     2763  27 Oct 89 22:32:12     uucp1/man/DCron
  57. X    1736  43%      984  14 Oct 89 15:38:24     uucp1/man/UUdecode
  58. X    1592  45%      871  14 Oct 89 15:38:26     uucp1/man/UUClean
  59. X    3569  49%     1837  14 Oct 89 15:38:26     uucp1/man/Grep
  60. X    2919  45%     1594  14 Oct 89 15:38:28     uucp1/man/UUlog
  61. X    1168  34%      772  27 Oct 89 22:33:42     uucp1/man/man
  62. X    2919  45%     1594  14 Oct 89 15:38:30     uucp1/man/UUCP
  63. X    1736  43%      984  14 Oct 89 15:38:32     uucp1/man/UUencode
  64. X    8139  53%     3832  14 Oct 89 15:38:20     uucp1/man/Tar
  65. X     380  25%      286  27 Oct 89 22:24:08     uucp1/man/From
  66. X     314  24%      240  14 Oct 89 15:38:20     uucp1/man/Rmail
  67. X    9043  49%     4593   8 Jan 90 23:33:20     uucp1/man/Domains
  68. X    2130  34%     1411  27 Oct 89 22:26:52     uucp1/man/Passwd
  69. X     572  22%      447  27 Oct 89 22:31:18     uucp1/man/NULL
  70. X    2380  38%     1479   7 Nov 89 16:46:26     uucp1/man/L.sys
  71. X    1178  31%      817   3 Nov 89 14:13:54     uucp1/man/Security
  72. X      22   0%       22   3 Nov 89 14:21:56     uucp1/man/.Distfiles
  73. X      62   0%       62   3 Nov 89 16:01:58     uucp1/man/Config
  74. X     559  32%      380  10 Jan 90 15:30:52     uucp1/src/TODO
  75. X   56681   0%    56681  14 Jan 90 19:13:36     uucp1/src/dmail.zoo
  76. X     496  23%      384  10 Jan 90 16:38:00     uucp1/src/sendmail/DMakefile
  77. X   22055  53%    10259  25 Jan 90 12:51:56     uucp1/src/sendmail/sendmail.c
  78. X    1232  37%      780  10 Jan 90 16:38:20     uucp1/src/sendmail/parse.c
  79. X    4164  44%     2317  25 Jan 90 12:41:10     uucp1/src/sendmail/domain.c
  80. X   40885  50%    20582   3 Nov 89 11:29:48     uucp1/src/compress/compress.c
  81. X    3856  40%     2321   3 Nov 89 11:30:10     uucp1/src/compress/tarsplit.c
  82. X     938  40%      565   3 Nov 89 16:08:56     uucp1/src/compress/DMakefile
  83. X    6648  47%     3544   3 Nov 89 11:30:36     uucp1/src/compress/unshar.c
  84. X    3204  40%     1923   3 Nov 89 11:30:50     uucp1/src/compress/uudecode.c
  85. X    2000  35%     1294   3 Nov 89 11:31:26     uucp1/src/compress/uuencode.c
  86. X       9   0%        9  31 Oct 89 14:23:22     uucp1/src/.Distfiles
  87. X    3865  41%     2266  10 Jan 90 16:39:30     uucp1/src/GUtil/uuserdump.c
  88. X     925  27%      677  10 Jan 90 16:38:54     uucp1/src/GUtil/uident.c
  89. X    3220  43%     1850  10 Jan 90 16:39:20     uucp1/src/GUtil/gnote.c
  90. X     676  30%      474  10 Jan 90 16:39:42     uucp1/src/GUtil/DMakefile
  91. X    1801  37%     1140  10 Jan 90 16:39:46     uucp1/src/MUtil/trimfile.c
  92. X    2388  41%     1410  10 Jan 90 16:40:00     uucp1/src/MUtil/from.c
  93. X    1032  35%      670   3 Nov 89 11:26:34     uucp1/src/MUtil/man.c
  94. X     579  32%      392   8 Jan 90 15:17:24     uucp1/src/MUtil/DMakefile
  95. X     432  21%      341  10 Jan 90 16:40:12     uucp1/src/MUtil/expandm.c
  96. X     811  29%      572  10 Jan 90 15:45:22     uucp1/src/ReadMe
  97. X    1459  31%     1006  25 Jan 90 14:18:26     uucp1/src/uucico/version.doc
  98. X   11298  47%     5942  10 Jan 90 15:31:28     uucp1/src/uucico/sysdep.c
  99. X   32949  50%    16420  25 Jan 90 14:10:38     uucp1/src/uucico/uucico.c
  100. X     974  41%      576  10 Jan 90 15:34:06     uucp1/src/uucico/DMakefile
  101. X     854  32%      582  14 Oct 89 15:39:52     uucp1/src/uucico/modem.h
  102. X    2378  39%     1440  25 Jan 90 14:12:44     uucp1/src/uucico/uuxqt.c
  103. X     939  23%      727  25 Jan 90 14:17:18     uucp1/src/uucico/uupoll.c
  104. X    3441  45%     1903  25 Jan 90 14:12:30     uucp1/src/uucico/uux.c
  105. X   16481  53%     7796  10 Jan 90 15:40:00     uucp1/src/uucico/gio.c
  106. X    1876  39%     1150  10 Jan 90 15:13:56     uucp1/src/uucico/sysdep.h
  107. X     675  18%      551  25 Jan 90 14:15:24     uucp1/src/uucico/uuname.c
  108. X    2821  42%     1627  23 Oct 89 17:41:24     uucp1/src/uucico/includes.h
  109. X     672  18%      549  25 Jan 90 14:12:24     uucp1/src/uucico/uuhosts.c
  110. X    3907  47%     2070  25 Jan 90 12:51:14     uucp1/src/uucico/uucp.c
  111. X    1358  27%      986  25 Oct 89 16:40:56     uucp1/src/uucico/uucp.h
  112. X    3471  39%     2106  10 Jan 90 16:41:24     uucp1/src/uucico/modem.c
  113. X     126   3%      122  10 Jan 90 16:41:46     uucp1/src/include/tmpfile.h
  114. X     330  25%      249  10 Jan 90 16:41:38     uucp1/src/include/log.h
  115. X    1625  34%     1080  10 Jan 90 16:42:08     uucp1/src/include/config.h
  116. X     540  35%      351  10 Jan 90 16:42:14     uucp1/src/include/pwd.h
  117. X     239  15%      203  10 Jan 90 16:42:38     uucp1/src/include/sys/stat.h
  118. X     125   3%      121  10 Jan 90 16:42:58     uucp1/src/include/sys/types.h
  119. X     136  17%      113  10 Jan 90 16:43:16     uucp1/src/include/sys/file.h
  120. X     107  10%       96  10 Jan 90 16:43:26     uucp1/src/include/sys/time.h
  121. X   19742  52%     9486   8 Jan 90 02:20:58     uucp1/src/getty/getty.c
  122. X     195   5%      185  10 Jan 90 16:43:56     uucp1/src/getty/syms.c
  123. X    1689  33%     1135  10 Jan 90 16:44:04     uucp1/src/getty/passwd.c
  124. X     369  23%      283  26 Oct 89 18:13:06     uucp1/src/getty/DMakefile
  125. X     834  34%      551  10 Jan 90 16:44:26     uucp1/src/lib/getenv.c
  126. X     156   1%      155  10 Jan 90 16:44:30     uucp1/src/lib/sleep.c
  127. X     519  26%      382  10 Jan 90 16:44:46     uucp1/src/lib/mntreq.c
  128. X     589  33%      394  10 Jan 90 16:44:18     uucp1/src/lib/string.c
  129. X     376  20%      302  10 Jan 90 16:44:54     uucp1/src/lib/tmpfile.c
  130. X    1505  39%      914  10 Jan 90 16:45:04     uucp1/src/lib/config.c
  131. X     815  28%      587  10 Jan 90 16:45:08     uucp1/src/lib/setstdin.c
  132. X    2562  39%     1551  10 Jan 90 16:45:24     uucp1/src/lib/serialport.c
  133. X     615  27%      449   6 Jan 90 00:27:02     uucp1/src/lib/DMakefile
  134. X    1815  42%     1052  14 Jan 90 19:05:52     uucp1/src/lib/getpwnam.c
  135. X    2345  41%     1380  10 Jan 90 16:45:36     uucp1/src/lib/lockfile.c
  136. X      49   0%       49  21 Oct 89 19:29:16     uucp1/src/lib/syms.c
  137. X    4268  45%     2353  10 Jan 90 16:45:48     uucp1/src/lib/alias.c
  138. X     643  31%      446  14 Jan 90 19:04:58     uucp1/src/lib/seq.c
  139. X    2279  40%     1358  14 Jan 90 19:06:06     uucp1/src/lib/security.c
  140. X     621  22%      485  14 Jan 90 19:06:16     uucp1/src/lib/lsys.c
  141. X    1273  34%      841  14 Jan 90 19:06:26     uucp1/src/lib/log.c
  142. X     338  24%      256  10 Jan 90 16:46:02     uucp1/src/lib/validuser.c
  143. X     705  23%      540  25 Jan 90 11:18:18     uucp1/src/version.h
  144. X   17361  48%     9096  10 Jan 90 16:24:30     uucp1/src/News060/rnews.c
  145. X    9639  49%     4887  10 Jan 90 18:47:40     uucp1/src/News060/Anews/anews.c
  146. X    2055  37%     1287  10 Jan 90 11:21:54     uucp1/src/News060/Anews/sendpacket.c
  147. X    2229  36%     1419  10 Jan 90 16:27:04     uucp1/src/News060/Anews/raw.c
  148. X    1607  33%     1069  10 Jan 90 16:27:36     uucp1/src/News060/Anews/mscan.c
  149. X     477  21%      376  10 Jan 90 16:27:42     uucp1/src/News060/Anews/DMakefile
  150. X    4092  45%     2239  25 Jan 90 13:56:46     uucp1/src/News060/postnews.c
  151. X     567  26%      420  10 Jan 90 16:28:06     uucp1/src/News060/DMakefile
  152. X    2039  36%     1303  10 Jan 90 16:28:20     uucp1/src/uuser/uuser.doc
  153. X    1880  39%     1154  10 Jan 90 16:29:12     uucp1/src/uuser/misc.c
  154. X     506  23%      391  10 Jan 90 16:29:34     uucp1/src/uuser/DMakefile
  155. X     100   7%       93  22 Oct 89 17:27:12     uucp1/src/uuser/mountlist
  156. X   13243  53%     6286  10 Jan 90 16:29:56     uucp1/src/uuser/uuser.c
  157. X   16308  25%    12188  25 Jan 90 23:03:22     uucp1/c/compress
  158. X    9284  23%     7183  25 Jan 90 23:03:14     uucp1/c/uuencode
  159. X   11000  23%     8449  25 Jan 90 23:03:16     uucp1/c/uudecode
  160. X   10720  23%     8215  25 Jan 90 23:03:16     uucp1/c/tarsplit
  161. X   26580  29%    18783  25 Jan 90 23:03:18     uucp1/c/tar
  162. X   10100  22%     7835  25 Jan 90 23:03:18     uucp1/c/man
  163. X    8048  22%     6283  25 Jan 90 23:03:20     uucp1/c/uident
  164. X   10828  23%     8345  25 Jan 90 23:03:20     uucp1/c/unshar
  165. X   10248  23%     7866  25 Jan 90 23:03:20     uucp1/c/from
  166. X--------  --- --------  --------- --------
  167. X  754104  41%   446333   128 files
  168. END_OF_FILE
  169. if test 9104 -ne `wc -c <'Disk2.contents'`; then
  170.     echo shar: \"'Disk2.contents'\" unpacked with wrong size!
  171. fi
  172. # end of 'Disk2.contents'
  173. fi
  174. if test -f 'man/Domains' -a "${1}" != "-c" ; then 
  175.   echo shar: Will not clobber existing file \"'man/Domains'\"
  176. else
  177. echo shar: Extracting \"'man/Domains'\" \(9043 characters\)
  178. sed "s/^X//" >'man/Domains' <<'END_OF_FILE'
  179. X
  180. XNAME
  181. X    UULIB:Domain
  182. X
  183. XSYNOPSIS
  184. X    -
  185. X
  186. XDESCRIPTION
  187. X
  188. X    The UULIB:Domain file holds routing information for addresses
  189. X    you send USENET mail to.  This file is normally required ONLY if
  190. X    your machine can talk to MORE THAN ONE USENET host.
  191. X
  192. X    For machines that can talk to ONLY ONE USENET host, you need
  193. X    only set the 'DefaultNode' entry in UULIB:Config to the name
  194. X    of the one host.
  195. X
  196. X    A domain is something like 'CTS.COM' or 'BERKELEY.EDU'.  Lets
  197. X    say you have direct USENET connections to UCBVAX.Berkeley.EDU and
  198. X    FUBAR.CTS.COM.
  199. X
  200. X    Now, you want to send an email message to CHARLIE.Berkeley.EDU
  201. X    and another email message to GALAXY.CTS.COM ... obviously you will
  202. X    want the first message to be routed through UCBVAX and the second
  203. X    routed through FUBAR.  The appropriate domain entries would be:
  204. X
  205. X    *.berkeley.edu  MF    UU  ucbvax.UUCP
  206. X    *.cts.com        MF    UU  fubar.UUCP
  207. X
  208. X    You will also want a default of some sort ... say you send mail
  209. X    to PHOTON.CSNET, you want unknown domains to be routed to somewhere
  210. X    that knows how to deal with them.  So you would also have another
  211. X    entry in UULIB:Domain:
  212. X
  213. X    *            MF    UU  ucbvax.UUCP
  214. X
  215. X    That specifies the machine to route mail through to reach an
  216. X    unknown address.
  217. X
  218. X    *** NOTE *** UUCP sites that you directly connect to need not be listed
  219. X    in UULIB:Domain, the UULIB:L.Sys file is automatically scanned for such
  220. X    sites.  For said machines any additional domain information is ignored
  221. X    (such as .UUCP).  In case the name of an immediately adjacent UUCP site
  222. X    conflicts with another site you can enter that other site into the domain
  223. X    list explicitly using the MD Type described below.
  224. X
  225. X            FORMAT OF DOMAIN FILE
  226. X
  227. X    Each line in the domain file may be blank, contain a '#' and then
  228. X    a comment, or contain a domain record.  Each domain record is broken
  229. X    up into four fields:
  230. X
  231. X    Domain Type Class Address-Info
  232. X
  233. X    Domain = domain in question, you may use '*' instead of a domain
  234. X         name to match ONE OR MORE SUBDOMAINS or the machine name.
  235. X         Case is ignored.
  236. X
  237. X         For example:   *.COM
  238. X                *.Berkeley.EDU
  239. X                *
  240. X
  241. X    Type   = MF or MD.    MF stands for mail forwarder, MD stands for
  242. X         mail destination.    The difference can be shown with an
  243. X         example:
  244. X
  245. X    ucbvax.berkeley.edu  MD UU  ucbvax.UUCP
  246. X    *.berkeley.edu         MF UU  ucbvax.UUCP
  247. X
  248. X    In the first case the domain is actually a complete machine
  249. X    name which we can directly talk to, thus MD is used telling
  250. X    the mail system that we REPLACE the address with this address.
  251. X
  252. X    In the second case the machine is what we must go THROUGH to
  253. X    reach machines with the given domain (note that more explicitly
  254. X    specified domains always have priority of less explicitly
  255. X    specified domains).  The mail system will PREPEND the address
  256. X    field with the forwarding machine address.
  257. X
  258. X    Class = UU
  259. X    Currently only UU, meaning USENET class, is supported.    This
  260. X    field is reserved to allow specification of different types
  261. X    of low level mailers so the mail system is not necessarily
  262. X    limited to using the USENET as the transport layer.
  263. X
  264. X    AddrInfo
  265. X    for the UU class AddrInfo contains a ! separated UUCP path
  266. X    where the first machine MUST be an immediately adjacent node.
  267. X    The remainder of the path is tagged onto the rmail line along
  268. X    with the original path specification.
  269. X
  270. X    NOTE:    For any machine in the bang (!) path of the AddrInfo
  271. X    field which is directly connected to the previous machine
  272. X    (the first machine is always directly connected to your
  273. X    machine), the domain is optional.  That is, the machine may
  274. X    be listed with or without a domain separated by dots.  The
  275. X    examples below show parts of paths both with and without
  276. X    domain names.
  277. X
  278. X    when you route through the INTERNET, however, you must be
  279. X    more careful.  Only known USENET paths may be addressed
  280. X    without worrying about the domain part of the machine name.
  281. X
  282. X            REGISTERED DOMAINS
  283. X
  284. X    We will eventually have our own domain that is registered with the
  285. X    network community.    When this occurs we will probably set up an
  286. X    automated system that keeps everybody's UULIB:Domain file consistant.
  287. X    Each UULIB:Domain file will then have an entry for all machines in
  288. X    our domain.  Thus, while UULIB:Domain is not being used so much at
  289. X    the moment I expect it will be used in a major way in the future.
  290. X
  291. X
  292. XADDRESSES IN A SMALL ISOLATED NETWORK
  293. X
  294. X    Using the UULIB:Domain file in local networks drastically
  295. X    simplifies most other parts of the UUCP mail system.  The
  296. X    greatest advantage of using a Domain file is that you can
  297. X    refer to machines in your local net by name rather than by
  298. X    path and can refer to them by name in any groups you might
  299. X    have constructed in UULIB:Aliases.    you can also use the Domain
  300. X    file to re-route email to machines that may have moved to
  301. X    somewhere else in your local network (say a buddy moves back
  302. X    east) without bouncing the email.  Which we can't do anyway yet..
  303. X    automatic bouncing will be in a future release.
  304. X
  305. X    Lets say you have a group of people all running UUCP connected
  306. X    like this:
  307. X                   d
  308. X                  /   f
  309. X                 /     /
  310. X            a---b---c---h
  311. X               /     \     \
  312. X              /       \   g
  313. X             x           e
  314. X
  315. X    If your machine is b.UUCP and you want to email to user@h.UUCP,
  316. X    then the appropriate path is:
  317. X
  318. X        To: c!h!user
  319. X
  320. X    If your machine is d.UUCP and you want to email to g.UUCP,
  321. X    then the appropriate path is:
  322. X
  323. X        To: b!c!g!user
  324. X
  325. X    There is another alternative.  You can setup your UULIB:Domain
  326. X    file with all of these paths and just say:
  327. X
  328. X        To: user@g.UUCP
  329. X
  330. X    The Domain file would be different for each node but you have
  331. X    removed the complexity one step.  The Domain file for a.UUCP
  332. X    would look like this:
  333. X
  334. X        *        MF UU   b.UUCP
  335. X
  336. X    This assumes that b.UUCP also implements Domains.  The Domain
  337. X    file for b.UUCP would look like this:
  338. X
  339. X        *        MF    UU  c.UUCP
  340. X        x.UUCP  MF    UU  a.UUCP
  341. X
  342. X    Because, apart from x.UUCP, the only nodes b.UUCP cannot reach
  343. X    directly are reachable via c.UUCP.
  344. X
  345. X    The Domain file for c.UUCP would be:
  346. X
  347. X        *        MF    UU  b.UUCP
  348. X
  349. X    Because the only nodes c.UUCP cannot reach go through b.UUCP,
  350. X    so we set the default route for unknown nodes to go through
  351. X    b.UUCP.  Here we assume that b.UUCP uses UULIB:Domains as
  352. X    well and knows how to get to x.UUCP which is not immediately
  353. X    adjacent to it.
  354. X
  355. X    The Domain file for c.UUCP assuming the b.UUCP does NOT use
  356. X    a Domains file (which is safest actually) is:
  357. X
  358. X        *        MF    UU  b.UUCP
  359. X        x.UUCP  MF    UU  b.UUCP!a.UUCP
  360. X
  361. X    Alternately you can use MD (mail destination):
  362. X
  363. X        *        MF    UU  b.UUCP
  364. X        x.UUCP  MD    UU  b.UUCP!a.UUCP!x.UUCP
  365. X
  366. XADDRESSES IN A SMALL NETWORK WITH A SINGLE CONNECTION TO THE OUTSIDE WORLD:
  367. X
  368. X                   d
  369. X                  /   f
  370. X                 /     /
  371. X            a---b---c---h---ucbvax.berkeley.edu
  372. X               /     \     \
  373. X              /       \   g
  374. X             x           e
  375. X
  376. X    This is another possible configuration... one person in your
  377. X    little Amiga network has a connection to the outside world.
  378. X    In this case everyone in your network should have UULIB:Domain
  379. X    entries to properly route email back and forth. Specifically, if
  380. X    you are giving somebody your email address and your machine is
  381. X    x.UUCP, you want to be able to give them:
  382. X
  383. X        ucbvax.berkeley.edu!h!x!user
  384. X
  385. X    As your address rather than
  386. X
  387. X        ucbvax.berkeley.edu!h!c!b!a!x!user
  388. X
  389. X    In otherwords, you want to HIDE your local network from the
  390. X    outside world.  This would require h.UUCP to have the
  391. X    following UULIB:Domain file:
  392. X
  393. X        *        MF    UU  ucbvax.berkeley.edu
  394. X        a.UUCP  MF    UU  c!b
  395. X        b.UUCP  MF    UU  c
  396. X        d.UUCP  MF    UU  c!b
  397. X        e.UUCP  MF    UU  c!b
  398. X        f.UUCP  MF    UU  c
  399. X        g.UUCP  MF    UU  c
  400. X        x.UUCP  MF    UU  c!b!a
  401. X
  402. X    Each of the other nodes in the network would have a similar
  403. X    Domain file.  Note that when you have a connection to the
  404. X    outside world the default, '*', should point to the outside
  405. X    world.  The '*' entry for a.UUCP, for example, would be:
  406. X
  407. X        *        MF    UU  b!c!h!ucbvax
  408. X
  409. X    If everyone in your local net implemented '*' properly it
  410. X    would suffice to redirect '*' to, say, just b.UUCP, and b.UUCP
  411. X    would direct it to c.UUCP, etc...  The cleanest way to deal
  412. X    with it is actually to redirect it to the last node in your
  413. X    local net that talks to the outside world:
  414. X
  415. X        *        MF    UU  b!c!h
  416. X
  417. X    This allows the sysop at h.UUCP the latitude to do further
  418. X    routing.  For example, what if h.UUCP was able to connect to
  419. X    two machines on the outside world!
  420. X
  421. X                  ucbvax.berkeley.edu
  422. X                 /
  423. X            ----h
  424. X                 \
  425. X                  pacbell.pacbell.com
  426. X
  427. X    In this case you want to give h.UUCP the latitude to redirect
  428. X    email to the .pacbell.com domain to pacbell.pacbell.com
  429. X    instead of going the long path through ucbvax.berkeley.edu ...
  430. X
  431. X        *            MF    UU  ucbvax
  432. X        *.PacBell.COM   MF    UU  pacbell
  433. X
  434. X    Thus, all the other nodes in your local network should direct
  435. X    unknown addresses through h.UUCP rather than bypass h.UUCP's
  436. X    domain system by giving an explicit route through it.
  437. X
  438. END_OF_FILE
  439. if test 9043 -ne `wc -c <'man/Domains'`; then
  440.     echo shar: \"'man/Domains'\" unpacked with wrong size!
  441. fi
  442. # end of 'man/Domains'
  443. fi
  444. if test -f 'man/Tar' -a "${1}" != "-c" ; then 
  445.   echo shar: Will not clobber existing file \"'man/Tar'\"
  446. else
  447. echo shar: Extracting \"'man/Tar'\" \(8139 characters\)
  448. sed "s/^X//" >'man/Tar' <<'END_OF_FILE'
  449. X
  450. XNAME
  451. X     tar - media file archiver
  452. X
  453. XSYNOPSIS
  454. X     tar -[BcDhikmopstvxzZ] [-b N] [-f F] [-T F] [ filename ... ]
  455. X
  456. XDESCRIPTION
  457. X     tar provides a way to store many files into a single
  458. X     archive, which can be kept in another file, stored on
  459. X     an I/O device such as tape, floppy, cartridge, or disk, or
  460. X     piped to another program. It is useful for making backup
  461. X     copies, or for packaging up a set of files to move them to
  462. X     another system.
  463. X
  464. X     When reading an archive, this version of tar continues after
  465. X     finding an error.  Previous versions required the `i' option
  466. X     to ignore checksum errors.
  467. X
  468. XOPTIONS
  469. X     tar options can be specified in either of two ways.  The
  470. X     usual Unix conventions can be used: each option is preceded
  471. X     by `-'; arguments directly follow each option; multiple
  472. X     options can be combined behind one `-' as long as they take
  473. X     no arguments.  For compatability with the Unix tar program,
  474. X     the options may also be specified as ``keyletters,'' wherein
  475. X     all the option letters occur in the first argument to tar,
  476. X     with no `-', and their arguments, if any, occur in the
  477. X     second, third, ...  arguments.  Examples:
  478. X
  479. X          Normal:  tar -f arcname -cv file1 file2
  480. X
  481. X          Old:  tar fcv arcname file1 file2
  482. X
  483. X     At least one of the -c, -t, or -x options must be included.
  484. X     The rest are optional.
  485. X
  486. X     Files to be operated upon are specified by a list of file
  487. X     names, which follows the option specifications (or can be
  488. X     read from a file by the -T option).  Specifying a directory
  489. X     name causes that directory and all the files it contains to
  490. X     be (recursively) processed.  In general, specifying full
  491. X     path names when creating an archive is a bad idea, since
  492. X     when the files are extracted, they will have to be extracted
  493. X     into exactly where they were dumped from.  Instead, cd to
  494. X     the root directory and use relative file names.
  495. X
  496. X     -b N Specify a blocking factor for the archive.  The block
  497. X          size will be N x 512 bytes.  Larger blocks typically
  498. X          run faster and let you fit more data on a tape.  The
  499. X          default blocking factor is set when tar is compiled,
  500. X          and is typically 20.  There is no limit to the maximum
  501. X          block size, as long as enough memory can be allocated
  502. X          for it, and as long as the device containing the
  503. X          archive can read or write that block size.
  504. X
  505. X     -B   When reading an archive, reblock it as we read it.
  506. X          Normally, tar reads each block with a single read(2)
  507. X          system call.  This does not work when reading from a
  508. X          pipe or network socket under Berkeley Unix.  With this
  509. X          option, it will do multiple read(2)s until it gets
  510. X          enough data to fill the specified block size.  -B can
  511. X          also be used to speed up the reading of tapes that were
  512. X          written with small blocking factors, by specifying a
  513. X          large blocking factor with -b and having tar read many
  514. X          small blocks into memory before it tries to process
  515. X          them.
  516. X
  517. X     -c   Create an archive from a list of files.
  518. X
  519. X     -D   With each message that tar produces, print the record
  520. X          number within the archive where the message occurred.
  521. X          This option is especially useful when reading damaged
  522. X          archives, since it helps to pinpoint the damaged sec-
  523. X          tion.
  524. X
  525. X     -f F Specify the filename of the archive.  If the specified
  526. X          filename is ``-'', the archive is read from the stan-
  527. X          dard input or written to the standard output.  If this
  528. X          option is not used, a default archive name (which was
  529. X          picked when tar was compiled) is used.  The default is
  530. X          normally set to the ``first'' tape drive or other tran-
  531. X          sportable I/O medium on the system.
  532. X
  533. X     -h   When creating an archive, if a symbolic link is encoun-
  534. X          tered, dump the file or directory to which it points,
  535. X          rather than dumping it as a symbolic link.
  536. X
  537. X     -i   When reading an archive, ignore blocks of zeros in the
  538. X          archive.  Normally a block of zeros indicates the end
  539. X          of the archive, but in a damaged archive, or one which
  540. X          was created by appending several archives, this option
  541. X          allows tar to continue.  It is not on by default
  542. X          because there is garbage written after the zeroed
  543. X          blocks by the Unix tar program.
  544. X
  545. X     -k   When extracting files from an archive, keep existing
  546. X          files, rather than overwriting them with the version
  547. X          from the archive.
  548. X
  549. X     -m   When extracting files from an archive, set each file's
  550. X          modified timestamp to the current time, rather than
  551. X          extracting each file's modified timestamp from the
  552. X          archive.
  553. X
  554. X     -o   When creating an archive, write an old format archive,
  555. X          which does not include information about directories,
  556. X          pipes, or device files, and specifies file ownership by
  557. X          uid's and gid's rather than by user names and group
  558. X          names.  In most cases, a ``new'' format archive can be
  559. X          read by an ``old'' tar program without serious trouble,
  560. X          so this option should seldom be needed.
  561. X
  562. X     -p   When extracting files from an archive, restore them to
  563. X          the same permissions that they had in the archive.  If
  564. X          -p is not specified, the current umask limits the per-
  565. X          missions of the extracted files.  See umask(2).
  566. X
  567. X     -t   List a table of contents of an existing archive.  If
  568. X          file names are specified, just list files matching the
  569. X          specified names.
  570. X
  571. X     -s   When specifying a list of filenames to be listed or
  572. X          extracted from an archive, the -s flag specifies that
  573. X          the list is sorted into the same order as the tape.
  574. X          This allows a large list to be used, even on small
  575. X          machines, because the entire list need not be read into
  576. X          memory at once.  Such a sorted list can easily be
  577. X          created by running ``tar -t'' on the archive and edit-
  578. X          ing its output.
  579. X
  580. X     -T F Rather than specifying the file names to operate on as
  581. X          arguments to the tar command, this option specifies
  582. X          that the file names should be read from the file F, one
  583. X          per line.  If the file name specified is ``-'', the
  584. X          list is read from the standard input.  This option, in
  585. X          conjunction with the -s option, allows an arbitrarily
  586. X          large list of files to be processed, and allows the
  587. X          list to be piped to tar.
  588. X
  589. X     -v   Be verbose about the files that are being processed or
  590. X          listed.  Normally, archive creation or file extraction
  591. X          are silent, and archive listing just gives file names.
  592. X          The -v option causes an ``ls -l''-like listing to be
  593. X          produced.
  594. X
  595. X     -x   Extract files from an existing archive.  If file name
  596. X          are specified, just extract files matching the speci-
  597. X          fied names, otherwise extract all the files in the
  598. X          archive.
  599. X
  600. X     -z or -Z
  601. X          When extracting or listing an archive, these options
  602. X          specify that the archive should be decompressed while
  603. X          it is read, using the -d option of the compress(1) pro-
  604. X          gram.  The archive itself is not modified.
  605. X
  606. XBUGS
  607. X     The r, u, w, X, l, F, C, and digit options of Unix tar are
  608. X     not supported.
  609. X
  610. X     It should be possible to create a compressed archive with
  611. X     the -z option.
  612. X
  613. X
  614. XNOTES ON AMIGA VERSION:
  615. X
  616. XAddendum for Version 1.1:
  617. X
  618. X     The -p option for extracting files with their dates
  619. X     preserved is now supported (under AmigaDos 1.2 only; do not
  620. X     try to use this option under AmigaDos 1.1).
  621. X
  622. XAddendum for Version 1.2:
  623. X
  624. X     The -p option now works on floppies as well as ram:. Various
  625. X     internal hacking has been done, and things are slightly
  626. X     different than before. The date conversion is now aware that
  627. X     it's summertime, and not wintertime (a change noticble only
  628. X     to people who've been porting tar archives back and forth
  629. X     between Unix and the Amiga).
  630. X
  631. END_OF_FILE
  632. if test 8139 -ne `wc -c <'man/Tar'`; then
  633.     echo shar: \"'man/Tar'\" unpacked with wrong size!
  634. fi
  635. # end of 'man/Tar'
  636. fi
  637. if test -f 'src/News060/Anews/anews.c' -a "${1}" != "-c" ; then 
  638.   echo shar: Will not clobber existing file \"'src/News060/Anews/anews.c'\"
  639. else
  640. echo shar: Extracting \"'src/News060/Anews/anews.c'\" \(9663 characters\)
  641. sed "s/^X//" >'src/News060/Anews/anews.c' <<'END_OF_FILE'
  642. X
  643. X/*
  644. X *  ANEWS.C
  645. X *
  646. X *  Copyright 1988 by William Loftus.  All rights reserved.
  647. X *
  648. X *  From William P. Loftus's UUCP0.60 distribution.
  649. X */
  650. X
  651. X#include <dos.h>
  652. X#include <stdio.h>
  653. X#include <stdlib.h>
  654. X#include <ctype.h>
  655. X#include "log.h"
  656. X#include "/version.h"
  657. X
  658. X#define YES         1
  659. X#define NO         0
  660. X#define ON         scr_inverse_on()
  661. X#define OFF         scr_inverse_off()
  662. X#define UL_On         printf("\x1b[4m")
  663. X#define UL_Off         printf("\x1b[0m")
  664. X#define Clear_eol    printf("\x9bK")
  665. X#define Clear_Screen printf("\x9bH\x9bJ")
  666. X#define Cr         printf("\xd")
  667. X#define PROG_NAME    "Anews"
  668. X
  669. X#define MAXGROUPS   512
  670. X
  671. XIDENT(".00");
  672. X
  673. Xint PageSize;
  674. Xint current = 0;
  675. Xint countgroups;
  676. Xint last[MAXGROUPS];          /*  Last read articles  */
  677. Xchar **ng;
  678. Xchar *get_next_file();
  679. Xchar fg,bg;
  680. Xchar homedir[128];
  681. Xchar *pager;
  682. X
  683. Xvoid init();
  684. Xvoid scan_subjects();
  685. Xvoid do_quit();
  686. Xvoid do_help1();
  687. Xvoid do_help2();
  688. Xvoid scr_inverse_on();
  689. Xvoid scr_inverse_off();
  690. Xvoid InitNewsrc();
  691. X
  692. Xchar **
  693. XGetNewsgroups_Lastread()
  694. X{
  695. X    FILE *fp;
  696. X    char buf[BUFSIZ];
  697. X    static char *ng[MAXGROUPS];
  698. X    int i;
  699. X
  700. X    if(!(fp=fopen("UUNEWS:newsrc","r"))) {
  701. X    printf("Anews: Error.. could not open UUNEWS:newsrc\n");
  702. X    printf("Creating file UUNEWS:newsrc from UUCP:Lib/newsgroups.\n");
  703. X    InitNewsrc();
  704. X    fp=fopen("UUNEWS:newsrc","r");
  705. X    }
  706. X
  707. X    for(i=0; i < MAXGROUPS; i++) {
  708. X    if (fscanf(fp,"%s %d",&buf,&last[i])==EOF)
  709. X        break;
  710. X    ng[i] = malloc(strlen(buf));
  711. X    strcpy(ng[i],buf);
  712. X    }
  713. X    fclose(fp);
  714. X    countgroups=i;
  715. X    return(ng);
  716. X}
  717. X
  718. X
  719. Xvoid
  720. XInitNewsrc()
  721. X{
  722. X    char buffer[80];
  723. X    FILE *fp_in, *fp_out;
  724. X
  725. X    if(!(fp_in=fopen("UULIB:newsgroups","r"))) {
  726. X    printf("Error:  Cannot open UULIB:newsgroups.\n");
  727. X    exit(0);
  728. X    }
  729. X
  730. X    if(!(fp_out=fopen("UUNEWS:newsrc","w"))) {
  731. X    printf("Error:  Cannot create newsrc file.\n");
  732. X    fclose(fp_in);
  733. X    exit(0);
  734. X    }
  735. X
  736. X    while(fscanf(fp_in,"%s",&buffer)!=EOF) {
  737. X    fprintf(fp_out,"%s %d\n",buffer,0);
  738. X    strset(buffer,NULL);
  739. X    }
  740. X
  741. X    fclose(fp_in); fclose(fp_out);
  742. X}
  743. X
  744. Xvoid
  745. Xmain(argc,argv)
  746. Xint argc;
  747. Xchar **argv;
  748. X{
  749. X    int ch;
  750. X
  751. X    LogProgram = "ANews";
  752. X    init();
  753. X    ng = GetNewsgroups_Lastread();
  754. X    raw(stdin);
  755. X    for (;;) {
  756. X    chdir("UUNEWS:");
  757. X    do {
  758. X        chdir(ng[current]);
  759. X        if (read_directory() != NULL) {
  760. X        ON;
  761. X        printf("Read %s? [y/n]",ng[current]);
  762. X        OFF;
  763. X        } else {
  764. X        if (ng[++current] == NULL)
  765. X            do_quit();
  766. X        ch = NULL;
  767. X        break;
  768. X        }
  769. X        putchar(' ');
  770. X        ch = getchar();
  771. X        printf("\n");
  772. X    } while ((ch == '\n') || (ch == '\r'));
  773. X
  774. X    switch (ch) {
  775. X    case 'Y':   /* Force the newsgroup to be read from the start..
  776. X             * We don't want to reset the last message read, so discard
  777. X             * the return
  778. X             */
  779. X        (void)readgroup(ng[current],last[current],1);
  780. X        break;
  781. X    case 'y':
  782. X        last[current] = readgroup(ng[current],last[current],0);
  783. X        break;
  784. X    case 'n':
  785. X    case 'N':
  786. X        if (ng[++current] == NULL)
  787. X        do_quit();
  788. X        break;
  789. X    case 'h':
  790. X    case 'H':
  791. X    case '?':
  792. X        do_help1();
  793. X        break;
  794. X    case 'q':
  795. X    case 'Q':
  796. X        do_quit();
  797. X    case '=':
  798. X        read_directory(NULL);
  799. X        scan_subjects();
  800. X        break;
  801. X    default:
  802. X        break;
  803. X    }
  804. X    }
  805. X}
  806. X
  807. Xchar *
  808. XGet_Env(envar, def)
  809. Xchar *envar, *def;
  810. X{
  811. X    char *p,*eptr,*getenv();
  812. X
  813. X    if ((p=getenv(envar)) != NULL) {
  814. X    eptr =(char *) malloc(strlen(p)+1);
  815. X    strcpy(eptr,p);
  816. X    } else
  817. X    eptr=def;
  818. X
  819. X    return(eptr);
  820. X}
  821. X
  822. Xvoid
  823. Xinit()
  824. X{
  825. X    getcwd(homedir, 128);
  826. X    chdir("UUNEWS:");
  827. X    pager = Get_Env("PAGER", "Sys:Utilities/More");
  828. X    fg = *Get_Env("FG","8");
  829. X    bg = *Get_Env("BG","0");
  830. X    PageSize = atoi(Get_Env("PAGESIZE", "20"));
  831. X}
  832. X
  833. Xchar *
  834. Xsubs(newsfile)
  835. Xchar *newsfile;
  836. X{
  837. X    FILE *fp;
  838. X    int j = 0;
  839. X    static char buf[BUFSIZ];
  840. X
  841. X    if ((fp = fopen(newsfile,"r")) == NULL) {
  842. X    printf(" Couldn't open %s\x1b[K\n",newsfile);
  843. X    return(NULL);
  844. X    }
  845. X    while ((j++ < 50) && fgets(buf,BUFSIZ,fp)) {
  846. X    if (strncmp("Subject:", buf, 8) == 0) {
  847. X        buf[strlen(buf)-1] = '\0';
  848. X        fclose(fp);
  849. X        return buf;
  850. X    }
  851. X    }
  852. X
  853. X    fclose(fp);
  854. X    return NULL;
  855. X}
  856. X
  857. Xvoid
  858. Xscan_subjects()
  859. X{
  860. X    char *ptr,ch,*s;
  861. X    int i,pos;
  862. X    extern int file_pointer;
  863. X
  864. X    pos = file_pointer;
  865. X
  866. X    i = 0;
  867. X    while (ptr = get_next_file()) {
  868. X    if (atoi(ptr) == 0)
  869. X        continue;
  870. X    if ((++i % PageSize) == 0) {
  871. X        ON;
  872. X        printf("(Hit any key to continue)");
  873. X        OFF;
  874. X        ch=getchar();
  875. X        Cr;
  876. X        Clear_eol;
  877. X        if (ch == 'q')
  878. X        break;
  879. X    }
  880. X    if (s = subs(ptr))
  881. X        printf("%s: %s\n",ptr,s);
  882. X    else
  883. X        printf("Error: No Subject line in %s\n",ptr);
  884. X    }
  885. X    file_pointer = pos;
  886. X}
  887. X
  888. Xvoid
  889. Xdo_quit()
  890. X{
  891. X    FILE *fp;
  892. X    int j;
  893. X
  894. X
  895. X    if(!(fp=fopen("UUNEWS:newsrc","w"))) {
  896. X    printf("Error, could not open UUNEWS:newsrc for writing.\n");
  897. X    } else {
  898. X    for(j = 0; j < countgroups; j++) {
  899. X        fprintf(fp,"%s %d\n",ng[j],last[j]);
  900. X    }
  901. X    }
  902. X    fclose(fp);
  903. X
  904. X    chdir(homedir);
  905. X    cooked(stdin);
  906. X    exit(0);
  907. X}
  908. X
  909. Xvoid
  910. Xdo_help1()
  911. X{
  912. X    printf("\x1b[0;1;33;40m");
  913. X    printf("Y      Read this newsgroup\n");
  914. X    printf("y      Read only new articles in this newsgroup\n");
  915. X    printf("n/N    Skip this newsgroup\n");
  916. X    printf("=      List article subjects in this newsgroup\n");
  917. X    printf("h/H/?  Display help\n");
  918. X    printf("q/Q    Quit to DOS\n");
  919. X    printf("\x1b[0;31;40m");
  920. X}
  921. X
  922. Xvoid
  923. Xdo_help2()
  924. X{
  925. X    printf("\x1b[0;1;33;40m");
  926. X    printf("\n(space)   Display next page of current article\n");
  927. X    printf("(return)  Same as (space)\n");
  928. X    printf("n/N       Goto the next article\n");
  929. X    printf("=         List article subjects for the remaining articles\n");
  930. X    printf("d/D       Delete this article\n");
  931. X    printf("-         Backup to previous article\n");
  932. X    printf("^         Goto the first article (sorry no $)\n");
  933. X    printf("(number)  Goto the given article number\n");
  934. X    printf("./>       Scan subject of next article, hit return to read it\n");
  935. X    printf(",/<       Backup one article, displaying its subject\n");
  936. X    printf("w/W       Write the current article to a file\n");
  937. X    printf("h/H/?     Display help\n");
  938. X    printf("q/Q       Quit this group and return to the main menu\n");
  939. X    printf("\x1b[0;31;40m");
  940. X}
  941. X
  942. Xreadgroup(group,lastread,force)
  943. Xchar *group;
  944. Xint lastread, force;
  945. X{
  946. X    char *name;
  947. X    FILE *fp;
  948. X    char buf[BUFSIZ], newname[40], temp[BUFSIZ];
  949. X    int i,done,ch,delete,last2;   /* Can't think of a different way to do it */
  950. X    extern int file_pointer;
  951. X
  952. X    if (force==1) {
  953. X    file_pointer=0;
  954. X    goto Forced;
  955. X    }
  956. X
  957. X    while ((atoi(name = get_next_file()) <= lastread) && name);
  958. X
  959. X    if (name == NULL) {
  960. X    Clear_Screen;
  961. X    printf("\nNo new news articles..\n");
  962. X    return (lastread);
  963. X    } else
  964. X    goto skipit;
  965. X
  966. X    /*
  967. X     *    we exit from that pointing to the last file we read..  this gets the
  968. X     *    first one we haven't read,   Falling Through CAN be fun ya know?
  969. X     */
  970. X
  971. X
  972. XForced:
  973. X    while(name=get_next_file()) {
  974. Xskipit:
  975. X    /* A necessary little kludge to remember the article number we are on */
  976. X    last2=atoi(name);
  977. X
  978. Xnamed_file:
  979. X    Clear_Screen;
  980. X    if ( (fp = fopen(name,"r")) == NULL) {
  981. X        printf("Article %s unavailable.\n",name);
  982. X        ON;
  983. X        printf("(Hit any key to continue)");
  984. X        OFF;
  985. X        getchar();
  986. X        continue;
  987. X    }
  988. X
  989. X    delete = done = NO;
  990. X    while (fgets(buf, BUFSIZ, fp) && (*buf != '\n')) {
  991. X        if ((strncmp(buf, "Subject",7) == 0)) {
  992. X        fputs("Subject: ", stdout);
  993. X        UL_On;
  994. X        fputs(buf+9, stdout);
  995. X        UL_Off;
  996. X        } else {
  997. X        fputs(buf,stdout);
  998. X        }
  999. X    }
  1000. X    do {
  1001. X        ON;
  1002. X        printf("%s [%s]?",group,name);
  1003. X        OFF;
  1004. X        putchar(' ');
  1005. X        ch = getchar();
  1006. X
  1007. X        /* Erase the prompt */
  1008. X        Cr;
  1009. X        Clear_eol;
  1010. X
  1011. X        switch (ch) {
  1012. X        case ' ':
  1013. X        case '\n':
  1014. X        case '\r':
  1015. X        case '\t':
  1016. X        i = 0;
  1017. X        do {
  1018. X            fputs(buf,stdout);
  1019. X        } while ((fgets(buf,BUFSIZ,fp) != NULL) && ( i++ <PageSize) );
  1020. X        break;
  1021. X
  1022. X        case '?':
  1023. X        case 'h':
  1024. X        case 'H':
  1025. X        ON;
  1026. X        printf("%s [%s]?",group,name);
  1027. X        OFF;
  1028. X        do_help2();
  1029. X        break;
  1030. X
  1031. X        case 'w':
  1032. X        case 'W':
  1033. X        ON;
  1034. X        printf("Write Article %s as ??", name);
  1035. X        OFF;
  1036. X        printf(" ");
  1037. X        strcpy(temp,"copy ");
  1038. X        strcat(temp,name);
  1039. X        strcat(temp," to ");
  1040. X        cooked(stdin);
  1041. X        gets(newname);
  1042. X        raw(stdin);
  1043. X        if (!*newname)
  1044. X            break;
  1045. X        strcat(temp,newname);
  1046. X        if (system(temp))
  1047. X            break;
  1048. X        printf("%s Saved to %s\n",name,newname);
  1049. X        break;
  1050. X
  1051. X        case '=':
  1052. X        scan_subjects();
  1053. X        break;
  1054. X        case 'q':
  1055. X        case 'Q':
  1056. X        fclose(fp);
  1057. X        return(last2>lastread?last2:lastread);
  1058. X        break;
  1059. X
  1060. X        case '-': if (file_pointer != 1)
  1061. X        file_pointer -= 2;;
  1062. X        done = YES;
  1063. X        break;
  1064. X
  1065. X        case '^':
  1066. X        file_pointer = 0;
  1067. X        done = YES;
  1068. X        break;
  1069. X
  1070. X        case '0':
  1071. X        case '1':
  1072. X        case '2':
  1073. X        case '3':
  1074. X        case '4':
  1075. X        case '5':
  1076. X        case '6':
  1077. X        case '7':
  1078. X        case '8':
  1079. X        case '9':
  1080. X        cooked(stdin);
  1081. X        newname[0] = ch;
  1082. X        ON;
  1083. X        printf("Goto Article");
  1084. X        OFF;
  1085. X        printf(" #%c",ch);
  1086. X        gets(newname+1);
  1087. X        raw(stdin);
  1088. X        fclose(fp);
  1089. X        name = newname;
  1090. X        goto named_file;
  1091. X
  1092. X        case '.':
  1093. X        case '>':
  1094. X        case ',':
  1095. X        case '<':
  1096. X        for(;;) {
  1097. X            char *strng;
  1098. X            strng=subs(name);
  1099. X            strng[strlen(strng)>49?50:strlen(strng)] = NULL;
  1100. X            printf("\r             #%-s\t%-50s\x1b[K",name,strng);
  1101. X            ON;
  1102. X            printf("\rGoto Article");
  1103. X            OFF;
  1104. X            switch (getchar()) {
  1105. X            case ',':
  1106. X            case '<':
  1107. X            file_pointer -= 2;
  1108. X            if (file_pointer <0)
  1109. X                file_pointer=0;
  1110. X            case '>':
  1111. X            case '.':
  1112. X            name=get_next_file();
  1113. X            break;
  1114. X            default:
  1115. X            goto named_file;
  1116. X            }
  1117. X        }
  1118. X
  1119. X        case 'd':
  1120. X        case 'D':
  1121. X        delete = YES;
  1122. X
  1123. X        case 'n':
  1124. X        case 'N':
  1125. X        done = YES;
  1126. X
  1127. X        default:
  1128. X        break;
  1129. X        }
  1130. X    } while (done == NO);
  1131. X
  1132. X    fclose(fp);
  1133. X    if (delete == YES) {
  1134. X        if (remove(name)) {
  1135. X        printf("Error deleting %s\n",name);
  1136. X        ulog(-1, "Error deleting %s", name);
  1137. X        }
  1138. X    }
  1139. X    }
  1140. X    return((last2 > lastread) ? last2 : lastread);
  1141. X}
  1142. X
  1143. Xvoid
  1144. Xscr_inverse_on()
  1145. X{
  1146. X   printf("\x9b\x37;3%c;4%cm",fg,bg);
  1147. X}
  1148. X
  1149. Xvoid
  1150. Xscr_inverse_off()
  1151. X{
  1152. X   printf("\x9b\x30;33;40m\033[0m");
  1153. X}
  1154. END_OF_FILE
  1155. if test 9663 -ne `wc -c <'src/News060/Anews/anews.c'`; then
  1156.     echo shar: \"'src/News060/Anews/anews.c'\" unpacked with wrong size!
  1157. fi
  1158. # end of 'src/News060/Anews/anews.c'
  1159. fi
  1160. if test -f 'src/dmail/commands.c' -a "${1}" != "-c" ; then 
  1161.   echo shar: Will not clobber existing file \"'src/dmail/commands.c'\"
  1162. else
  1163. echo shar: Extracting \"'src/dmail/commands.c'\" \(10361 characters\)
  1164. sed "s/^X//" >'src/dmail/commands.c' <<'END_OF_FILE'
  1165. X
  1166. X/*
  1167. X * COMMANDS.C
  1168. X *
  1169. X *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  1170. X *
  1171. X *  Global Routines:    DO_QUIT()
  1172. X *            DO_EXIT()
  1173. X *            DO_CD()
  1174. X *            DO_ECHO()
  1175. X *            DO_GO()
  1176. X *            DO_SOURCE()
  1177. X *            DO_SHELL()
  1178. X *            DO_WRITE()
  1179. X *            DO_DELNEXT()
  1180. X *            DO_NUMBER()
  1181. X *            DO_NEXT()
  1182. X *            DO_HEADER()
  1183. X *            DO_TYPE()
  1184. X *            DO_DELETE()
  1185. X *            DO_UNDELETE()
  1186. X *            DO_MARK()
  1187. X *        DO_BREAK()
  1188. X *
  1189. X *  Static Routines:    None.
  1190. X *
  1191. X */
  1192. X
  1193. X#include <stdio.h>
  1194. X#include <sys/file.h>
  1195. X#include "dmail.h"
  1196. X
  1197. X#define LAST_TYPE   0
  1198. X#define LAST_HEADER 1
  1199. X
  1200. Xstatic int Last_operation;
  1201. Xstatic int Last_deleted = -1;
  1202. Xstatic char ScrBuf[1024];
  1203. X
  1204. Xvoid
  1205. Xdo_quit(garbage, com)
  1206. Xchar *garbage;
  1207. X{
  1208. X    int fd, r, back;
  1209. X    char *str;
  1210. X
  1211. X    push_break();
  1212. X    if (get_inode (mail_file) == get_inode (output_file)) {
  1213. X    back = save_file (0, 0, ST_DELETED | ST_STORED);
  1214. X    } else {
  1215. X    r = write_file (output_file, O_CREAT, ST_READ, ST_DELETED | ST_STORED);
  1216. X    if (r < 0) {
  1217. X        printf ("Unable to write to %s\n", output_file);
  1218. X        back = save_file (0, 0, ST_DELETED | ST_STORED);
  1219. X    } else {
  1220. X        back = save_file (0, 0, ST_READ | ST_DELETED | ST_STORED);
  1221. X    }
  1222. X    }
  1223. X    if (back < 0)
  1224. X    printf ("Unable to update %s\n", mail_file);
  1225. X    if (back > 0)
  1226. X    printf ("%d  kept in %s\n", back, mail_file);
  1227. X    sleep (1);
  1228. X    if ((fd = open (mail_file, O_RDONLY, 0)) >= 0) {
  1229. X    read (fd, Buf, 1);
  1230. X    close (fd);
  1231. X    }
  1232. X    if (!com)
  1233. X    done (0);
  1234. X    free_entry();
  1235. X    if (av[1] == 0) {
  1236. X    if (!Silence)
  1237. X        puts ("NO FROM FILE SPECIFIED");
  1238. X    av[1] = mail_file;
  1239. X    av[2] = NULL;
  1240. X    }
  1241. X    Did_cd = 0;
  1242. X    mail_file = realloc (mail_file, strlen(av[1]) + 1);
  1243. X    strcpy (mail_file, av[1]);
  1244. X    str = (av[2]) ? av[2] : mail_file;
  1245. X    output_file = realloc (output_file, strlen(str) + 1);
  1246. X    strcpy (output_file, str);
  1247. X    initial_load_mail();
  1248. X    m_select (Nulav, M_RESET);
  1249. X    pop_break();
  1250. X    if (!Silence)
  1251. X    printf ("\nRF %-20s   WF %-20s\n", mail_file, output_file);
  1252. X}
  1253. X
  1254. Xvoid
  1255. Xdo_exit(garbage, com)
  1256. Xchar *garbage;
  1257. X{
  1258. X    char *str;
  1259. X
  1260. X    if (!com)
  1261. X    done (0);
  1262. X    push_break();
  1263. X    free_entry();
  1264. X    if (av[1] == 0) {
  1265. X    if (!Silence)
  1266. X        puts ("NO FROM FILE SPECIFIED");
  1267. X    av[1] = mail_file;
  1268. X    av[2] = NULL;
  1269. X    }
  1270. X    mail_file = realloc (mail_file, strlen(av[1]) + 1);
  1271. X    strcpy (mail_file, av[1]);
  1272. X    str = (av[2]) ? av[2] : mail_file;
  1273. X    output_file = realloc (output_file, strlen(str) + 1);
  1274. X    strcpy (output_file, str);
  1275. X    initial_load_mail();
  1276. X    m_select (Nulav, M_RESET);
  1277. X    pop_break();
  1278. X    if (!Silence)
  1279. X    printf ("\nRF %-20s   WF %-20s\n", mail_file, output_file);
  1280. X}
  1281. X
  1282. X
  1283. Xdo_cd()
  1284. X{
  1285. X    char *dir = (ac < 2) ? home_dir : av[1];
  1286. X
  1287. X    if (chdir(dir) < 0) {
  1288. X    printf ("Cannot CD to %s\n", dir);
  1289. X    return (-1);
  1290. X    }
  1291. X    ++Did_cd;
  1292. X    return (1);
  1293. X}
  1294. X
  1295. X
  1296. Xdo_echo(str)
  1297. Xchar *str;
  1298. X{
  1299. X    puts (next_word(str));
  1300. X    fflush(stdout);
  1301. X    return (1);
  1302. X}
  1303. X
  1304. X
  1305. Xdo_go()
  1306. X{
  1307. X    int i;
  1308. X
  1309. X    if (ac < 2) {
  1310. X    puts ("go to which article?");
  1311. X    }
  1312. X    rewind_range (1);
  1313. X    i = get_range();
  1314. X    if (i < 0) {
  1315. X    if (!Silence)
  1316. X        printf ("Message #%d does not exist\n", i);
  1317. X    return (-1);
  1318. X    }
  1319. X    if (i == 0) {
  1320. X    if (!Silence)
  1321. X        puts ("No Message");
  1322. X    return (-1);
  1323. X    }
  1324. X    Current = indexof(i);
  1325. X    return (1);
  1326. X}
  1327. X
  1328. X
  1329. Xdo_source(scratch, overide)
  1330. Xchar *scratch;
  1331. X{
  1332. X    char *comline = malloc(1024);
  1333. X    FILE *fi = NULL;
  1334. X
  1335. X    if (ac < 2) {
  1336. X    puts ("No file argument to source");
  1337. X    free(comline);
  1338. X    return (-1);
  1339. X    }
  1340. X    if (push_base()) {
  1341. X    push_break();
  1342. X    pop_base();
  1343. X    if (fi != NULL)
  1344. X        fclose (fi);
  1345. X    pop_break();
  1346. X    free(comline);
  1347. X    return (-1);
  1348. X    }
  1349. X    push_break();
  1350. X    fi = fopen (av[1], "r");
  1351. X    pop_break();
  1352. X    if (fi == NULL) {
  1353. X    if (!overide)
  1354. X        printf ("Cannot open %s\n", av[1]);
  1355. X    free(comline);
  1356. X    return (-1);
  1357. X    }
  1358. X    while (fgets (comline, 1024, fi) != NULL) {
  1359. X    comline[strlen(comline) - 1] = '\0';
  1360. X    if (comline[0] != '#')
  1361. X        exec_command (comline);
  1362. X    }
  1363. X    push_break();
  1364. X    fclose (fi);
  1365. X    fi = NULL;
  1366. X    free(comline);
  1367. X    pop_break();
  1368. X    pop_base();
  1369. X    return (1);
  1370. X}
  1371. X
  1372. X
  1373. Xdo_shell(str)
  1374. Xchar *str;
  1375. X{
  1376. X#ifdef UNIX
  1377. X    int pid, ret;
  1378. X#endif
  1379. X    char *shell, *ptr;
  1380. X    char *args;
  1381. X
  1382. X#ifdef AMIGA
  1383. X    shell = "";
  1384. X#else
  1385. X    shell = getenv("SHELL");
  1386. X#endif
  1387. X    if (shell == NULL)
  1388. X    shell = "/bin/sh";
  1389. X    ptr = shell + strlen(shell) - 1;
  1390. X    while (ptr > shell && *ptr && *ptr != '/')
  1391. X    --ptr;
  1392. X    args = (strcmp(ptr, "/sh"))? "-fc" : "-c";
  1393. X    push_break();
  1394. X    str = next_word (str);
  1395. X#ifdef UNIX
  1396. X    if (strlen (str)) {
  1397. X    if ((pid = vfork()) == 0) {
  1398. X        execl (shell, shell, args, str, NULL);
  1399. X        _exit (1);
  1400. X    }
  1401. X    } else {
  1402. X    if ((pid = vfork()) == 0) {
  1403. X        execl (shell, shell, NULL);
  1404. X        _exit (1);
  1405. X    }
  1406. X    }
  1407. X    while ((ret = wait(0)) > 0) {
  1408. X    if (ret == pid)
  1409. X        break;
  1410. X    }
  1411. X#endif
  1412. X#ifdef AMIGA
  1413. X    Execute(str, NULL, NULL);
  1414. X#endif
  1415. X    pop_break();
  1416. X    return (1);
  1417. X}
  1418. X
  1419. X
  1420. Xdo_write()
  1421. X{
  1422. X    char *file;
  1423. X    int r, count = 0;
  1424. X    register int i, j;
  1425. X
  1426. X    if (ac < 2) {
  1427. X    puts ("You must specify at least a file-name");
  1428. X    return (-1);
  1429. X    }
  1430. X    file = av[1];
  1431. X    rewind_range (2);
  1432. X    push_break();
  1433. X    while (i = get_range()) {
  1434. X    j = indexof (i);
  1435. X    if (j >= 0  &&  !(Entry[j].status & ST_DELETED)) {
  1436. X        Entry[j].status |= ST_STORED | ST_SCR;
  1437. X        ++count;
  1438. X    }
  1439. X    }
  1440. X    r = write_file (file, O_CREAT, ST_SCR, 0);
  1441. X    rewind_range (2);
  1442. X    if (r > 0) {
  1443. X    while (i = get_range()) {
  1444. X        j = indexof (i);
  1445. X        if (j >= 0)
  1446. X        Entry[j].status &= ~ST_SCR;
  1447. X    }
  1448. X    if (!Silence)
  1449. X        printf ("%d Items written\n", count);
  1450. X    } else {
  1451. X    while (i = get_range()) {
  1452. X        j = indexof (i);
  1453. X        if (j >= 0)
  1454. X        Entry[j].status &= ~(ST_SCR | ST_STORED);
  1455. X    }
  1456. X    printf ("Could not write to file %s\n", file);
  1457. X    }
  1458. X    pop_break();
  1459. X    return (1);
  1460. X}
  1461. X
  1462. X/*
  1463. X * DB, added 3 Oct 1988
  1464. X */
  1465. X
  1466. Xdo_delprev()
  1467. X{
  1468. X    do_mark("", ST_DELETED);
  1469. X    if (Current)
  1470. X    return(do_next("", -1));
  1471. X    return(-1);
  1472. X}
  1473. X
  1474. Xdo_delnext()
  1475. X{
  1476. X    static int warning;
  1477. X
  1478. X    if (!warning  &&  Last_operation == LAST_HEADER) {
  1479. X    ++warning;
  1480. X    puts ("Note that the next command is displaying headers only at");
  1481. X    puts ("this point.  (one-time warning, NOTHING deleted");
  1482. X    return (-1);
  1483. X    }
  1484. X    if (do_mark("", ST_DELETED) > 0)
  1485. X    return (do_next("", 1));
  1486. X    return (-1);
  1487. X}
  1488. X
  1489. X
  1490. Xdo_number(str, com)
  1491. Xchar *str;
  1492. Xint com;
  1493. X{
  1494. X    int x;
  1495. X
  1496. X    x = indexof (atoi(str));
  1497. X    if (x < 0) {
  1498. X    puts ("Non existant message");
  1499. X    return (-1);
  1500. X    }
  1501. X    Current = x;
  1502. X    switch (Last_operation) {
  1503. X    case LAST_TYPE:
  1504. X    return (do_type());
  1505. X    case LAST_HEADER:
  1506. X    return (do_header());
  1507. X    default:
  1508. X    puts ("Internal Error NEXT");
  1509. X    return (-1);
  1510. X    }
  1511. X}
  1512. X
  1513. X
  1514. Xdo_next(str, com)
  1515. Xchar *str;
  1516. X{
  1517. X    int ok;
  1518. X
  1519. X    push_break();
  1520. X    if (com > 0) {
  1521. X    if (++Current > Entries)
  1522. X        Current = Entries;
  1523. X    if (fix() < 0) {
  1524. X        puts ("End of file");
  1525. X        pop_break();
  1526. X        return (-1);
  1527. X    }
  1528. X    --com;
  1529. X    }
  1530. X    if (com < 0) {
  1531. X    ++com;
  1532. X    ok = 0;
  1533. X    while (--Current >= 0) {
  1534. X        if (Entry[Current].no  &&  !(Entry[Current].status & ST_DELETED)) {
  1535. X        ok = 1;
  1536. X        break;
  1537. X        }
  1538. X    }
  1539. X    if (!ok) {
  1540. X        puts ("Start of file");
  1541. X    Current = 0;
  1542. X        fix();
  1543. X        pop_break();
  1544. X        return (-1);
  1545. X    }
  1546. X    }
  1547. X    pop_break();
  1548. X    if (!com) {
  1549. X    switch (Last_operation) {
  1550. X    case LAST_TYPE:
  1551. X        return (do_type());
  1552. X    case LAST_HEADER:
  1553. X        return (do_header());
  1554. X    }
  1555. X    }
  1556. X    return (1);
  1557. X}
  1558. X
  1559. X
  1560. Xdo_header()
  1561. X{
  1562. X    Last_operation = LAST_HEADER;
  1563. X    if (push_base()) {
  1564. X    push_break();
  1565. X    pop_base();
  1566. X    PAGER (-1);
  1567. X    fseek (m_fi, 0, 0);
  1568. X    fflush (stdout);
  1569. X    pop_break();
  1570. X    return (-1);
  1571. X    }
  1572. X    if (single_position() < 0)
  1573. X    return (-1);
  1574. X    if (Current < 0) {
  1575. X    puts("Software error #commands.0");
  1576. X    exit(1);
  1577. X    }
  1578. X    PAGER (0);
  1579. X    sprintf (Puf, "MESSAGE HEADER #%d (%d) %s\n",
  1580. X        Entry[Current].no,
  1581. X        Current + 1,
  1582. X        (Entry[Current].status & ST_DELETED) ? "  DELETED" : "");
  1583. X    PAGER (Puf);
  1584. X    sprintf (Puf, "From %s\n", Entry[Current].from);
  1585. X    PAGER (Puf);
  1586. X    while (fgets (ScrBuf, 1024, m_fi) != NULL) {
  1587. X    FPAGER (ScrBuf);
  1588. X    if (*ScrBuf == '\n') {
  1589. X        PAGER (-1);
  1590. X        pop_base();
  1591. X        return (1);
  1592. X    }
  1593. X    }
  1594. X    PAGER ("END OF FILE ENCOUNTERED");
  1595. X    PAGER (-1);
  1596. X    pop_base();
  1597. X    return (-1);
  1598. X}
  1599. X
  1600. Xdo_type()
  1601. X{
  1602. X    int i;
  1603. X
  1604. X    Last_operation = LAST_TYPE;
  1605. X    if (push_base()) {
  1606. X    push_break();
  1607. X    pop_base();
  1608. X    PAGER (-1);
  1609. X    fseek (m_fi, 0, 0);
  1610. X    fflush (stdout);
  1611. X    pop_break();
  1612. X    return (-1);
  1613. X    }
  1614. X    if (single_position() < 0)
  1615. X    return (-1);
  1616. X    if (Current < 0) {
  1617. X    puts("Software Error #commands.1");
  1618. X    exit(1);
  1619. X    }
  1620. X    if (skip_to_data (m_fi) < 0) {
  1621. X    printf ("Cannot find data for message %d\n", Entry[Current].no);
  1622. X    return (-1);
  1623. X    }
  1624. X    PAGER (0);
  1625. X    sprintf (Puf, "MESSAGE TEXT #%d (%d) %s\n",
  1626. X        Entry[Current].no,
  1627. X        Current + 1,
  1628. X        (Entry[Current].status & ST_DELETED) ? "  DELETED" : "");
  1629. X    PAGER (Puf);
  1630. X    for (i = 0; i < Listsize; ++i) {
  1631. X    if (*Entry[Current].fields[header[i]]) {
  1632. X        sprintf (Puf, "%-10s %s",
  1633. X            Find[header[i]].search,
  1634. X            Entry[Current].fields[header[i]]);
  1635. X        PAGER (Puf);
  1636. X    }
  1637. X    }
  1638. X    PAGER ("");
  1639. X    while ((fgets (ScrBuf, 1024, m_fi) != NULL)  &&  strncmp (ScrBuf, "From ", 5))
  1640. X    FPAGER (ScrBuf);
  1641. X    Entry[Current].status |= ST_READ;
  1642. X    PAGER (-1);
  1643. X    pop_base();
  1644. X    return (1);
  1645. X}
  1646. X
  1647. X
  1648. Xdo_mark(garbage, mask)
  1649. Xchar *garbage;
  1650. X{
  1651. X    int count = 0;
  1652. X    register int i, j;
  1653. X
  1654. X    rewind_range (1);
  1655. X    push_break();
  1656. X    while (i = get_range()) {
  1657. X    j = indexof (i);
  1658. X    if (j >= 0) {
  1659. X        if (mask & ST_DELETED)
  1660. X        Last_deleted = j;
  1661. X        if ((Entry[j].status & mask) != mask) {
  1662. X        Entry[j].status |= mask;
  1663. X        if (Entry[j].status & ST_DELETED)
  1664. X            Entry[j].status &= ~(ST_STORED | ST_READ | ST_TAG);
  1665. X        ++count;
  1666. X        }
  1667. X    }
  1668. X    }
  1669. X    if (!Silence)
  1670. X    printf ("%d  Items\n", count);
  1671. X    pop_break();
  1672. X    return (1);
  1673. X}
  1674. X
  1675. X
  1676. Xdo_unmark(garbage, mask)
  1677. Xchar *garbage;
  1678. X{
  1679. X    int count = 0;
  1680. X    register int i, j;
  1681. X    register struct ENTRY *en;
  1682. X
  1683. X    push_break();
  1684. X    if (ac == 1 && (mask & ST_DELETED) && Last_deleted != -1)  {
  1685. X    en = &Entry[Last_deleted];
  1686. X    if (en->no) {
  1687. X        en->status &= ~mask;
  1688. X        printf ("Undeleted last deleted message (# %d)\n", en->no);
  1689. X        Current = Last_deleted;
  1690. X        Last_deleted = -1;
  1691. X    } else {
  1692. X        puts ("Last deleted message not within current select bounds");
  1693. X        pop_break();
  1694. X        return (-1);
  1695. X    }
  1696. X    pop_break();
  1697. X    return (1);
  1698. X    }
  1699. X    rewind_range (1);
  1700. X    while (i = get_range()) {
  1701. X    j = indexof (i);
  1702. X    if (j >= 0) {
  1703. X        if (Entry[j].status & mask) {
  1704. X        Entry[j].status &= ~mask;
  1705. X        ++count;
  1706. X        }
  1707. X    }
  1708. X    }
  1709. X    if (!Silence)
  1710. X    printf ("%d  Items\n", count);
  1711. X    pop_break();
  1712. X    return ((count) ? 1 : -1);
  1713. X}
  1714. X
  1715. Xdo_break(garbage, mask)
  1716. Xchar *garbage;
  1717. X{
  1718. X    if (mask)
  1719. X    pop_break();
  1720. X    else
  1721. X    push_break();
  1722. X    return (1);
  1723. X}
  1724. X
  1725. Xvoid
  1726. Xdo_ver()
  1727. X{
  1728. X    puts (DVERSION);
  1729. X}
  1730. X
  1731. END_OF_FILE
  1732. if test 10361 -ne `wc -c <'src/dmail/commands.c'`; then
  1733.     echo shar: \"'src/dmail/commands.c'\" unpacked with wrong size!
  1734. fi
  1735. # end of 'src/dmail/commands.c'
  1736. fi
  1737. if test -f 'src/dmail/sendmail.c' -a "${1}" != "-c" ; then 
  1738.   echo shar: Will not clobber existing file \"'src/dmail/sendmail.c'\"
  1739. else
  1740. echo shar: Extracting \"'src/dmail/sendmail.c'\" \(9206 characters\)
  1741. sed "s/^X//" >'src/dmail/sendmail.c' <<'END_OF_FILE'
  1742. X
  1743. X/*
  1744. X *  SENDMAIL.C
  1745. X *
  1746. X *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  1747. X *
  1748. X *  Global Routines:    DO_REPLY()
  1749. X *            DO_MAIL()
  1750. X *
  1751. X *  Static Routines:    WORD_SIZE()
  1752. X *            FOPEN_SCRATCH()
  1753. X *            FREOPEN_SCRATCH()
  1754. X *            FCLOSE_SCRATCH()
  1755. X *            FTERMINATE_SCRATCH()
  1756. X *            DELETE_SCRATCH()
  1757. X *            RUN_VI()
  1758. X *            SEND_MAIL()
  1759. X *
  1760. X *
  1761. X */
  1762. X
  1763. X#include <stdio.h>
  1764. X#include <sys/types.h>
  1765. X#include <sys/stat.h>
  1766. X#include <sys/file.h>
  1767. X#ifdef UNIX
  1768. X#include <sys/ioctl.h>
  1769. X#endif
  1770. X#include <sys/time.h>
  1771. X#include <signal.h>
  1772. X#include "dmail.h"
  1773. X
  1774. X#ifdef AMIGA
  1775. X#include <dos.h>
  1776. X
  1777. Xstruct XFORKENV {
  1778. X    long    env_priority;
  1779. X    long    env_stack;
  1780. X    long    env_stdin;
  1781. X    long    env_stdout;
  1782. X    long    env_console;
  1783. X    long    env_msgport;
  1784. X};
  1785. X
  1786. X#endif
  1787. X
  1788. XFILE *fi;
  1789. Xchar file[64];
  1790. X
  1791. Xvoid fclose_scratch();
  1792. Xvoid fopen_scratch();
  1793. Xvoid copy_header();
  1794. Xvoid send_mail();
  1795. X
  1796. Xdo_reply(garbage, itext)
  1797. Xchar *garbage;
  1798. X{
  1799. X    int i, j;
  1800. X    int anyargs  = 0;
  1801. X    int to_field, cc_field;
  1802. X    int len;
  1803. X    char *ptr;
  1804. X    static char buf[1024];
  1805. X    char scr;
  1806. X    char *istr;
  1807. X
  1808. X    if (!(istr = get_var(LEVEL_SET, "_headchar")))
  1809. X    istr = ">";
  1810. X    if (push_base()) {
  1811. X    push_break();
  1812. X    pop_base();
  1813. X    fclose_scratch();
  1814. X    puts ("ABORTED, no mail sent");
  1815. X    unlink(file);
  1816. X    pop_break();
  1817. X    return (-1);
  1818. X    }
  1819. X    fopen_scratch();
  1820. X    strcpy (buf, "To: ");
  1821. X    for (i = 1; i < ac; ++i) {
  1822. X    if (*av[i] >= '0'  &&  *av[i] <= '9') {
  1823. X        if ((j = indexof(atoi(av[i]))) < 0) {
  1824. X        puts ("No such message");
  1825. X        fclose_scratch();
  1826. X        unlink(file);
  1827. X        pop_break();
  1828. X        return (-1);
  1829. X        }
  1830. X        Current = j;
  1831. X    } else {
  1832. X        if (anyargs)
  1833. X        strcat (buf, ", ");
  1834. X        anyargs = 1;
  1835. X        strcat (buf, av[i]);
  1836. X    }
  1837. X    }
  1838. X    len = strlen(buf);
  1839. X    switch (itext) {
  1840. X    case R_FORWARD:
  1841. X    strcat (buf, "\n");
  1842. X    fputs (buf, fi);
  1843. X    fputs ("Subject: \n", fi);
  1844. X    break;
  1845. X    case R_INCLUDE:
  1846. X    case R_REPLY:
  1847. X    if (anyargs) {
  1848. X        strcat (buf, ", ");
  1849. X        len = strlen(buf);
  1850. X    }
  1851. X    buf[len] = 0;
  1852. X    if (Current >= 0) {
  1853. X        char *rf = get_var(LEVEL_SET, "replyfields");
  1854. X        if (rf == NULL)
  1855. X        rf = "";
  1856. X        while (*rf) {       /* attempt to find the fields listed */
  1857. X        char *re;
  1858. X        char *ptr;
  1859. X        char c;
  1860. X        for (re = rf; *re && *re != ' ' && *re != 9; ++re);
  1861. X        c = *re;
  1862. X        *re = 0;
  1863. X        ptr = get_field(rf);
  1864. X        if (*ptr) {
  1865. X            *re = c;
  1866. X            sprintf (buf + len, "%s\n", ptr);
  1867. X            break;
  1868. X        }
  1869. X        *re = c;
  1870. X        while (*re == ' ' || *re == 9)
  1871. X            ++re;
  1872. X        rf = re;
  1873. X        }
  1874. X        if (*rf == 0) {
  1875. X        sprintf (buf + len, "%.*s\n",
  1876. X            word_size(Entry[Current].from), Entry[Current].from);
  1877. X        }
  1878. X    }
  1879. X    fputs (buf, fi);
  1880. X    fputs ("Cc: ", fi);
  1881. X    ptr = get_field ("To:");
  1882. X    to_field = (*ptr) ? 1 : 0;
  1883. X    fputs (ptr, fi);
  1884. X    scr = *(ptr + strlen(ptr) - 1);
  1885. X    ptr = get_field ("Cc:");
  1886. X    cc_field = (*ptr) ? 1 : 0;
  1887. X    if (cc_field) {
  1888. X        if (scr == '\n') {
  1889. X        fputs ("         ", fi);
  1890. X        }
  1891. X        if (to_field)
  1892. X        fputs (", ", fi);
  1893. X        fputs (ptr, fi);
  1894. X    }
  1895. X    fputs ("\nSubject: Re: ", fi);
  1896. X    fputs (get_field ("Subject:"), fi);
  1897. X    fputs ("\n", fi);
  1898. X    break;
  1899. X    case R_MAIL:
  1900. X    fputs (buf, fi);
  1901. X    fputs ("\n", fi);
  1902. X    fputs ("Cc: \n", fi);
  1903. X    fputs ("Bcc: \n", fi);
  1904. X    fputs ("Subject: \n", fi);
  1905. X    break;
  1906. X    default:
  1907. X    puts ("INTERNAL STUPID MAIL ERROR: REPLY");
  1908. X    break;
  1909. X    }
  1910. X    copy_header (fi);
  1911. X    fputs ("\n\n", fi);
  1912. X    if (itext == R_FORWARD  ||  itext == R_INCLUDE) {
  1913. X    position_current();
  1914. X    if (itext == R_FORWARD) {
  1915. X        if (Current >= 0)
  1916. X        fprintf (fi, "ORIGINALLY From %s\n", Entry[Current].from);
  1917. X    } else {
  1918. X        skip_to_data (m_fi);
  1919. X    }
  1920. X    while ((fgets (Buf, MAXFIELDSIZE, m_fi) != NULL) && !isfrom(Buf)) {
  1921. X        if (itext == R_INCLUDE)
  1922. X        fputs(istr, fi);
  1923. X        fputs (Buf, fi);
  1924. X    }
  1925. X    fputs ("\n", fi);
  1926. X    }
  1927. X    fclose_scratch();
  1928. X    if (itext != R_MAIL) {
  1929. X    push_break();
  1930. X    if (Current >= 0) {
  1931. X        Entry[Current].status |= ST_SCR;
  1932. X        write_file("tmp:Original", O_CREAT | O_TRUNC, ST_SCR, 0);
  1933. X        Entry[Current].status &= ~ST_SCR;
  1934. X    }
  1935. X    pop_break();
  1936. X    }
  1937. X    j = -1;
  1938. Xloop:
  1939. X    ++j;
  1940. X    if (run_vi() || j) {
  1941. X    push_break();
  1942. X    switch (do_ask()) {
  1943. X    case 1:
  1944. X        puts ("SENDING.. wait");
  1945. X        send_mail();
  1946. X        {
  1947. X        FILE *li = fopen(file, "r");
  1948. X        char buf[128], *ptr = NULL;
  1949. X
  1950. X        if (li) {
  1951. X            while (fgets(buf, 128, li) && buf[0] != '\n') {
  1952. X            if (strncmp(buf, "Farchive:", 9) == 0) {
  1953. X                buf[strlen(buf)-1] = '\0';
  1954. X                for (ptr = buf + 9; *ptr == ' '; ++ptr);
  1955. X                if (ptr[0] == '$')
  1956. X                ptr = get_var(LEVEL_SET, ptr+1);
  1957. X                break;
  1958. X            }
  1959. X            }
  1960. X            fclose(li);
  1961. X        }
  1962. X        archive_mail(ptr);
  1963. X        }
  1964. X        unlink(file);
  1965. X        break;
  1966. X    case 2:
  1967. X        pop_break();
  1968. X        goto loop;
  1969. X    default:
  1970. X        unlink (file);
  1971. X        break;
  1972. X    }
  1973. X    pop_base();
  1974. X    pop_break();
  1975. X    } else {
  1976. X    puts ("File not modified or ABORTED, no mail sent");
  1977. X    unlink(file);
  1978. X    pop_base();
  1979. X    }
  1980. X    unlink ("#");
  1981. X}
  1982. X
  1983. Xdo_ask()
  1984. X{
  1985. X    char in[256];
  1986. X
  1987. X    if (!S_ask)
  1988. X    return (1);
  1989. X    fputs ("\n(Send, Vi, Quit) ?", stdout);
  1990. X    fflush(stdout);
  1991. X    gets (in);
  1992. X    switch (in[0]) {
  1993. X    case 's':
  1994. X    case 'S':
  1995. X    return (1);
  1996. X    case 'q':
  1997. X    case 'Q':
  1998. X    puts ("ABORT, no mail sent");
  1999. X    return (3);
  2000. X    case 'v':
  2001. X    case 'V':
  2002. X    default:
  2003. X    return (2);
  2004. X    }
  2005. X}
  2006. X
  2007. X
  2008. X
  2009. Xstatic void
  2010. Xcopy_header(fi)
  2011. XFILE *fi;
  2012. X{
  2013. X    FILE *fs;
  2014. X    char *ptr;
  2015. X
  2016. X    if (ptr = get_var (LEVEL_SET, "header")) {
  2017. X    push_break();
  2018. X    if ((fs = fopen (ptr, "r")) != NULL) {
  2019. X        while (fgets (Buf, MAXFIELDSIZE, fs) != NULL)
  2020. X        fputs (Buf, fi);
  2021. X        fclose (fs);
  2022. X    } else {
  2023. X        printf ("Cannot open header file %d %s\n", strlen(ptr), ptr);
  2024. X        perror ("fopen");
  2025. X    }
  2026. X    pop_break();
  2027. X    }
  2028. X}
  2029. X
  2030. X
  2031. Xstatic void
  2032. Xfopen_scratch()
  2033. X{
  2034. X    static int c;
  2035. X    int fd;
  2036. X
  2037. X    sprintf(file, "tmp:dmt%d%d", getpid(), c++);
  2038. X    fd = open(file, O_RDWR|O_CREAT|O_TRUNC, 0700);
  2039. X    if (fd < 0) {
  2040. X    perror ("Dmail, cannot open scratch file");
  2041. X    done (1);
  2042. X    }
  2043. X#ifdef AMIGA        /*    fix bug in Lattice C fdopen */
  2044. X    fi = fopen("nil:", "w");
  2045. X    fclose(fi);
  2046. X#endif
  2047. X    fi = fdopen(fd, "w+");
  2048. X}
  2049. X
  2050. Xstatic void
  2051. Xfclose_scratch()
  2052. X{
  2053. X    if (fi != NULL) {
  2054. X    fflush (fi);
  2055. X    fclose (fi);
  2056. X    fi = NULL;
  2057. X    }
  2058. X}
  2059. X
  2060. X
  2061. Xstatic
  2062. Xword_size(str)
  2063. Xregister char *str;
  2064. X{
  2065. X    register int size = 0;
  2066. X
  2067. X    while (*str) {
  2068. X    if (*str == ' ')
  2069. X        return (size);
  2070. X    ++str;
  2071. X    ++size;
  2072. X    }
  2073. X    return (size);
  2074. X}
  2075. X
  2076. X
  2077. Xstatic
  2078. Xrun_vi()
  2079. X{
  2080. X#ifdef UNIX
  2081. X    char buf[64];
  2082. X    int ret, pid = 0;
  2083. X#endif
  2084. X    struct stat stat1, stat2;
  2085. X    char *argv[3];
  2086. X
  2087. X    argv[0] = visual;
  2088. X    argv[1] = file;
  2089. X    argv[2] = NULL;
  2090. X    if (push_base()) {
  2091. X    push_break();
  2092. X    pop_base();
  2093. X#ifdef UNIX
  2094. X    if (pid) {
  2095. X        kill (pid, SIGKILL);
  2096. X        sprintf (buf, "tmp:Ex%d", pid); unlink (buf);
  2097. X        sprintf (buf, "tmp:Rx%d", pid); unlink (buf);
  2098. X        wait(0);
  2099. X        system ("clear; reset ; clear");
  2100. X        pid = 0;
  2101. X    }
  2102. X#endif
  2103. X    pop_break();
  2104. X    return (0);
  2105. X    }
  2106. X    stat1.st_mtime = stat2.st_mtime = stat1.st_ctime = stat2.st_ctime = 0;
  2107. X    stat (file, &stat1);
  2108. X    if (S_novibreak)
  2109. X    push_break();
  2110. X
  2111. X#ifdef UNIX
  2112. X    pid = vfork();
  2113. X    if (!pid) {
  2114. X    execv (visual, argv);
  2115. X    printf ("Cannot exec visual: %s\n", visual);
  2116. X    _exit (1);
  2117. X    }
  2118. X    while ((ret = wait(0)) > 0) {
  2119. X    if (ret == pid)
  2120. X        break;
  2121. X    }
  2122. X#endif
  2123. X#ifdef AMIGA
  2124. X    {
  2125. X    short i;
  2126. X    static char buf[128];
  2127. X
  2128. X    strcpy(buf, argv[0]);
  2129. X    for (i = 1; argv[i]; ++i) {
  2130. X        strcat(buf, " ");
  2131. X        strcat(buf, argv[i]);
  2132. X    }
  2133. X    Execute(buf, NULL, NULL);
  2134. X    }
  2135. X#endif
  2136. X    if (S_novibreak)
  2137. X    pop_break();
  2138. X    stat (file, &stat2);
  2139. X    pop_base();
  2140. X    return (!(stat1.st_mtime==stat2.st_mtime));
  2141. X}
  2142. X
  2143. X
  2144. X#ifdef UNIX
  2145. X
  2146. Xstatic void
  2147. Xsend_mail()
  2148. X{
  2149. X    int fd, stdin_fd;
  2150. X    char *argv[6];
  2151. X
  2152. X    push_break();
  2153. X    argv[0] = S_sendmail;
  2154. X    argv[1] = "-t";
  2155. X    argv[2] = "-oem";
  2156. X    argv[3] = "-i";
  2157. X    if (S_verbose) {
  2158. X    argv[4] = "-v";
  2159. X    argv[5] = NULL;
  2160. X    } else {
  2161. X    argv[4] = NULL;
  2162. X    }
  2163. X
  2164. X    fd = open (file, O_RDONLY, 0);
  2165. X    if (fd < 0) {
  2166. X    perror ("Dmail, Cannot open scratch file");
  2167. X    done (1);
  2168. X    }
  2169. X    lseek(fd, 0, 0);
  2170. X
  2171. X    stdin_fd = dup (0);
  2172. X    dup2 (fd, 0);       /* STDIN = message file */
  2173. X    close(fd);          /* don't need message file anymore  */
  2174. X    if (!fork()) {
  2175. X    int fd = open("/dev/tty", O_RDWR, 0);
  2176. X    if (fd >= 0) {
  2177. X        ioctl(fd, TIOCNOTTY, 0);
  2178. X        close(fd);
  2179. X        freopen("/dev/null", "w", stdout);
  2180. X        freopen("/dev/null", "w", stderr);
  2181. X    }
  2182. X    execv (S_sendmail, argv);
  2183. X    printf ("Unable to exec sendmail: %s\n", S_sendmail);
  2184. X    _exit (1);
  2185. X    }
  2186. X    dup2 (stdin_fd, 0);     /* restore STDIN    */
  2187. X    close(stdin_fd);
  2188. X    if (S_verbose) {
  2189. X    puts ("Waiting for sendmail...");
  2190. X    wait (0);
  2191. X    puts ("Sendmail done");
  2192. X    }
  2193. X    pop_break();
  2194. X}
  2195. X
  2196. X#endif
  2197. X#ifdef AMIGA
  2198. X
  2199. Xstatic void
  2200. Xsend_mail()
  2201. X{
  2202. X    static char Buf[256];
  2203. X
  2204. X    push_break();
  2205. X    sprintf(Buf, "%s < %s%s -f %s", S_sendmail, file, (S_verbose ? " -v" : ""), user_name);
  2206. X
  2207. X    printf("Sending\n");
  2208. X    if (Execute(Buf, NULL, NULL) == 0)
  2209. X    printf("Unable to run: %s\n", Buf);
  2210. X
  2211. X    pop_break();
  2212. X}
  2213. X
  2214. X#endif
  2215. X
  2216. X
  2217. X
  2218. X
  2219. X
  2220. Xstatic
  2221. Xarchive_mail(ptr)
  2222. Xchar *ptr;
  2223. X{
  2224. X    FILE *ifi, *ofi;
  2225. X    long tim = time(NULL);
  2226. X
  2227. X    if (!ptr)
  2228. X    ptr = get_var(LEVEL_SET, "archive");
  2229. X    if (ptr == NULL || *ptr == '\0')
  2230. X    return(-1);
  2231. X    ifi = fopen(file, "r");
  2232. X    if (ifi == NULL) {
  2233. X    puts ("Cannot open scratch file");
  2234. X    return(-1);
  2235. X    }
  2236. X    ofi = fopen(ptr, "a");
  2237. X    if (ofi == NULL) {
  2238. X    puts ("Cannot open archive file");
  2239. X    fclose(ifi);
  2240. X    return(-1);
  2241. X    }
  2242. X    sprintf (Buf, "\nFrom %s (ARCHIVE)\n", user_name);
  2243. X    fputs (Buf, ofi);
  2244. X    sprintf (Buf, "Date: %s", ctime(&tim));
  2245. X    fputs (Buf, ofi);
  2246. X    while (fgets (Buf, MAXFIELDSIZE, ifi))
  2247. X    fputs (Buf, ofi);
  2248. X    fclose(ofi);
  2249. X    fclose(ifi);
  2250. X    return (1);
  2251. X}
  2252. X
  2253. X
  2254. END_OF_FILE
  2255. if test 9206 -ne `wc -c <'src/dmail/sendmail.c'`; then
  2256.     echo shar: \"'src/dmail/sendmail.c'\" unpacked with wrong size!
  2257. fi
  2258. # end of 'src/dmail/sendmail.c'
  2259. fi
  2260. echo shar: End of archive 6 \(of 16\).
  2261. cp /dev/null ark6isdone
  2262. MISSING=""
  2263. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  2264.     if test ! -f ark${I}isdone ; then
  2265.     MISSING="${MISSING} ${I}"
  2266.     fi
  2267. done
  2268. if test "${MISSING}" = "" ; then
  2269.     echo You have unpacked all 16 archives.
  2270.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2271. else
  2272.     echo You still need to unpack the following archives:
  2273.     echo "        " ${MISSING}
  2274. fi
  2275. ##  End of shell archive.
  2276. exit 0
  2277. -- 
  2278. Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
  2279.     amiga@cs.odu.edu    
  2280. or    amiga@xanth.cs.odu.edu    ( obsolescent mailers may need this address )
  2281. or    ...!uunet!xanth!amiga    ( very obsolescent mailers need this address )
  2282.  
  2283. Comments, questions, and suggestions should be addressed to ``amiga-request''
  2284. (please only use ``amiga'' for actual submissions) at the above addresses.
  2285.